﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using MJM.SEDIC.EN;
using MJM.CBD.Conn;

namespace MJM.SEDIC.AD
{
    public static class AccesoAD
    {
        public static int Insertar(AccesoEN obj)
        {
            int codigo = 1;
            SqlConnection conn=new SqlConnection(Cadena.GetCadenaVecinos());
            SqlCommand cmd = new SqlCommand("sp_i_T_WEB_MENUSU_Insertar", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            try
            {
                cmd.Parameters.Add(new SqlParameter("@vOPTUSU_P_inID", obj.IdPermiso));
                cmd.Parameters.Add(new SqlParameter("@vSUBMEN_P_inID", obj.IdSubMenu));
                cmd.Connection.Open();
                cmd.ExecuteNonQuery();
                cmd.Connection.Close();
                cmd.Dispose();
                conn.Dispose();
            }
            catch(Exception ex)
            {
                cmd.Dispose();
                conn.Dispose();
                codigo = 1;
            }
            return codigo;
        }
    }
}
